package edu.hrbu.trade01.controller;

import edu.hrbu.trade01.annotation.MyLog;
import edu.hrbu.trade01.entity.Trans;
import edu.hrbu.trade01.service.TransService;
import edu.hrbu.trade01.util.R;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

import static edu.hrbu.trade01.util.ConstUtil.LOG_TITLE_UPDATE;
import static edu.hrbu.trade01.util.ConstUtil.LOG_TYPE_PROFESSION;

/**
 * @author 徐登宇
 */
@RestController
@RequestMapping("/trans")
public class TransController {

    @Resource(name = "transServiceImpl")
    private TransService transService;

    @RequestMapping("/list")
    public R list() {
        List<Trans> list = transService.list();
        return R.ok(list);
    }

    @MyLog(title = LOG_TITLE_UPDATE,businessType = LOG_TYPE_PROFESSION)
    @PostMapping("/update")
    public R update(@RequestBody Trans trans){
        transService.updateById(trans);
        return R.ok();
    }

}
